package com.ck.client.dao;


import com.ck.common.model.bo.DeviceKeyMsg;
import com.ck.common.model.bo.DeviceReportBO;
import org.apache.ibatis.annotations.Param;
import com.ck.common.model.Device;

import java.util.List;

public interface DeviceInfoMapper {

	/**
	 * 保存终端
	 *
	 * @param device Device类型对象
	 */
	int registerDevice(Device device);

	/**
	 * 通过code获取终端
	 *
	 * @param deviceCode
	 * @return Device
	 */
	Device getDeviceInfoByCode(@Param("deviceCode") String deviceCode);

	/**
	 * 更新终端上报信息
	 *
	 * @param reportDevice
	 * @return
	 */
	int deviceReport(DeviceReportBO reportDevice);

	/**
	 * 更新终端表版本升级信息
	 *
	 * @param deviceCode
	 * @param softwareVersion
	 * @param softwareUpgradeTime
	 * @param firmwareVersion
	 * @param firmwareUpgradeTime
	 * @return
	 */
	int updateDeviceUpgradeInfo(@Param("deviceCode") String deviceCode,
								@Param("softwareVersion") String softwareVersion, @Param("softwareUpgradeTime") Long softwareUpgradeTime,
								@Param("firmwareVersion") String firmwareVersion, @Param("firmwareUpgradeTime") Long firmwareUpgradeTime);

	/**
	 * 终端是否已经存在
	 *
	 * @param deviceCode
	 * @return
	 */
	int isAlreadyExists(@Param("deviceCode") String deviceCode);

	/**
	 * 根据设备序列号获取设备关键信息
	 *
	 * @param deviceCode
	 * @return
	 */
	DeviceKeyMsg getDeviceKeyMsg(@Param("deviceCode") String deviceCode);

	/**
	 * 设备二次注册
	 *
	 * @param deviceCode
	 * @param token
	 * @param deviceGroupId
	 * @param bindingTime
	 * @return
	 */
	int secondRegister(@Param("deviceCode") String deviceCode, @Param("token") String token, @Param("deviceGroupId") Long deviceGroupId, @Param("lastBindingTime") Long bindingTime);

	/**
	 * 设置设备附属信息
	 *
	 * @param deviceCode
	 * @param deviceMac
	 * @param modelName
	 * @param resolution
	 * @return
	 */
    int setDeviceInfo(@Param("deviceCode") String deviceCode, @Param("deviceMac") String deviceMac, @Param("modelName") String modelName, @Param("resolution") String resolution);

	/**
	 * 获取离线设备的唯一编码
	 *
	 * @param timeDiff
	 * @return
	 */
	List<String> getOffLineDevice(@Param("timeDiff") Long timeDiff);

	/**
	 * 设置数据库设备状态为离线
	 *
	 * @param timeDiff
	 * @return
	 */
	int setDeviceOffLine(@Param("timeDiff") Long timeDiff);

	/**
	 * 获取终端分辨率
	 *
	 * @param deviceCode
	 * @return
	 */
    String getDeviceResolution(@Param("deviceCode") String deviceCode);

	/**
	 * 设备唯一编码替换
	 *
	 * @param deviceCode
	 * @param uniqueDeviceCode
	 */
	void replaceDeviceCode(@Param("deviceCode") String deviceCode, @Param("uniqueDeviceCode") String uniqueDeviceCode);
}
